﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SmartSpace.UI.Silverlight;
using WorkSpace.UI.Windows;
using System.Json;
using WorkSpace.UI.Controls;
using WorkSpace.UI.WorkSpaceRef;

namespace WorkSpace.UI
{
    /// <summary>
    /// 1.添加属于自己的类别和连接
    /// 2.分配连接给下面的机构
    /// </summary>
    public partial class LinkManagementView : AppView
    {
        public LinkManagementView()
            : base(new Guid("{F436A676-F525-4B19-8D23-59598D95B7BA}"), "Link Management View")
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
        }

        protected override void OnExtendShown()
        {
            if (IsFirstDisplay)
            {
                this._ctlCategoryListPart.LoadDatas(Authentication.Account);

                LoadDatas();
            }
        }

        private void LoadDatas()
        {
            WorkSpaceRef.WorkSpaceWebServiceSoapClient client = WorkSpaceModule.CreateWorkSpaceWebServiceProxy();
            client.GetInheritiedLinksCompleted += new EventHandler<GetInheritiedLinksCompletedEventArgs>(client_GetInheritiedLinksCompleted);
            client.GetInheritiedLinksAsync();
        }

        void client_GetInheritiedLinksCompleted(object sender, GetInheritiedLinksCompletedEventArgs e)
        {
            if (e.Error == null && e.Result.IsSuccess == true)
            {
                _ctlGridLink.ItemsSource = e.Result.Data;
            }
        }
    }
}
